]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
network: fix handling of AP flags and enhance for 802.1x
authorDan Williams <dcbw@redhat.com>
Tue, 3 May 2011 17:21:45 +0000 (12:21 -0500)
committerDan Williams <dcbw@redhat.com>
Wed, 4 May 2011 15:20:21 +0000 (10:20 -0500)
All WPA APs were getting set as WPA2 due to the check for privacy;
WPA/WPA2 APs *must* set the Privacy bit according to the standard,
so we'd never end up in the case for NMAccessPointSecurity.WPA.

Fix that, and also add flags for WPA[2] Enterprise which we'll
use a bit later for the first-time connect case for 802.1x enabled
access points.

js/ui/status/network.js

index bf8e272656c36bf0e7fe677ff1ab99be69d0df9c..6f0cdac032d448f5e301fc501730abf95b6d69cd 100644 (file)
@@ -33,8 +33,10 @@ const NMAccessPointSecurity = {
     UNKNOWN: 0,
     NONE: 1,
     WEP: 2,
-    WPA: 3,
-    WPA2: 4
+    WPA_PSK: 3,
+    WPA2_PSK: 4,
+    WPA_ENT: 5,
+    WPA2_ENT: 6
 };
 
 // small optimization, to avoid using [] all the time
@@ -1129,26 +1131,28 @@ NMDeviceWireless.prototype = {
     _getApSecurityType: function(accessPoint) {
         if (accessPoint._secType)
             return accessPoint._secType;
-        // XXX: have this checked by someone familiar with IEEE 802.1x
 
         let flags = accessPoint.flags;
         let wpa_flags = accessPoint.wpa_flags;
         let rsn_flags = accessPoint.rsn_flags;
         let type;
-        if (  !(flags & NM80211ApFlags.PRIVACY)
-             && (wpa_flags == NM80211ApSecurityFlags.NONE)
-             && (rsn_flags == NM80211ApSecurityFlags.NONE))
-           type = NMAccessPointSecurity.NONE;
-        else if (   (flags & NM80211ApFlags.PRIVACY)
-                   && (wpa_flags == NM80211ApSecurityFlags.NONE)
-                   && (rsn_flags == NM80211ApSecurityFlags.NONE))
-           type = NMAccessPointSecurity.WEP;
-        else if (   !(flags & NM80211ApFlags.PRIVACY)
-               &&  (wpa_flags != NM80211ApSecurity.NONE)
-               &&  (rsn_flags != NM80211ApSecurity.NONE))
-           type = NMAccessPointSecurity.WPA;
-        else
-            type = NMAccessPointSecurity.WPA2;
+        if (rsn_flags != NM80211ApSecurityFlags.NONE) {
+            /* RSN check first so that WPA+WPA2 APs are treated as RSN/WPA2 */
+            if (rsn_flags & NM80211ApSecurityFlags.KEY_MGMT_802_1X)
+               type = NMAccessPointSecurity.WPA2_ENT;
+           else if (rsn_flags & NM80211ApSecurityFlags.KEY_MGMT_PSK)
+               type = NMAccessPointSecurity.WPA2_PSK;
+        } else if (wpa_flags != NM80211ApSecurityFlags.NONE) {
+            if (wpa_flags & NM80211ApSecurityFlags.KEY_MGMT_802_1X)
+                type = NMAccessPointSecurity.WPA_ENT;
+            else if (wpa_flags & NM80211ApSecurityFlags.KEY_MGMT_PSK)
+               type = NMAccessPointSecurity.WPA_PSK;
+        } else {
+            if (flags & NM80211ApFlags.PRIVACY)
+                type = NMAccessPointSecurity.WEP;
+            else
+                type = NMAccessPointSecurity.NONE;
+        }
 
         // cache the found value to avoid checking flags all the time
         accessPoint._secType = type;